package com.kzj.mls.recyclerCard.cardView;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.kzj.mls.R;
import com.kzj.mls.beans.BookDateTime;
import com.kzj.mls.recyclerCard.basic.CardItemView;
import com.kzj.mls.recyclerCard.basic.MaterialListAdapter;
import com.kzj.mls.recyclerCard.basic.MaterialListView;
import com.kzj.mls.recyclerCard.card.other.ChooseRightTimeCard;

import de.greenrobot.event.EventBus;

/**
 * Created by xyg on 2015/11/9.
 */
public class ChooseTimeRightCardView extends CardItemView<ChooseRightTimeCard> {

    private Context context;
    private TextView textView_time;
    private ImageView imageView_icon;
    /*private TextView textView_title;*/

    public ChooseTimeRightCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public ChooseTimeRightCardView(Context context) {
        super(context);
        this.context = context;
    }

    public ChooseTimeRightCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(final ChooseRightTimeCard card) {
        super.build(card);
        textView_time = (TextView) findViewById(R.id.textView_time);
        textView_time.setText(card.getHourEntity().getTime_format());
        imageView_icon=(ImageView) findViewById(R.id.imageView_icon);
        //先判断booktime
        if (card.getHourEntity().getIsset())
        {
            setBackgroundColor(getResources().getColor(R.color.color_f875a3_red));
            imageView_icon.setVisibility(View.VISIBLE);
          //  textView_time.setEnabled(false);
        }
        else
        {
            setBackgroundColor(getResources().getColor(R.color.color_30_gray));
            imageView_icon.setVisibility(View.INVISIBLE);
          //  textView_time.setEnabled(false);
        }


            setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    EventBus.getDefault().post(card);
/*
                    BookDateTime bookDateTime = card.getBookDateTime();
                    bookDateTime.setBooking_time(textView_time.getText().toString());
                    EventBus.getDefault().post(bookDateTime);

                    for (int i = 0; i < materialListViewTime.getAdapter().getItemCount(); i++) {
                        ChooseRightTimeCard chooseRightTimeCard = (ChooseRightTimeCard) ((MaterialListAdapter) materialListViewTime.getAdapter()).getCard(i);
                        chooseRightTimeCard.setIsSelected(false);
                    }

                    card.setIsSelected(true);
                    materialListViewTime.getAdapter().notifyDataSetChanged();*/

                }
            });



    }
}
